package sword_to_1;

import java.util.Arrays;

public class LeeCode_56_2 {
    public static void main(String[] args) {

    }
    private static int singleNumber(int[] nums) {
        Arrays.sort(nums);
        if (nums.length == 1){
            return nums[0];
        }
        if (nums[0] != nums[1]){
            return nums[0];
        }
        for (int i = 1; i < nums.length - 1; i++) {
            if (nums[i] != nums[i - 1] && nums[i] != nums[i + 1]){
                return nums[i];
            }
        }
        return nums[nums.length - 1];
    }
}
